define(['jquery'], function ($) {
  'use strict';
  return {
    // 获取URL参数
    getQueryParams: function (url) {
      var queryParams = {};
      var queryString = url.split('?')[1] || '';
      var regExp = /([^&=]+)=([^&]*)/g;
      var match;
      while ((match = regExp.exec(queryString)) !== null) {
        var key = decodeURIComponent(match[1]);
        var value = decodeURIComponent(match[2]);
        queryParams[key] = value;
      }
      return queryParams;
    },
    // 比较两个版本号
    compareVersions: function (version1, version2) {
      var ver1Parts = version1.split('.').map(Number);
      var ver2Parts = version2.split('.').map(Number);
      var maxLength = Math.max(ver1Parts.length, ver2Parts.length);
      for (var i = 0; i < maxLength; i++) {
        var part1 = ver1Parts[i] || 0;
        var part2 = ver2Parts[i] || 0;
        if (part1 < part2) return -1;
        if (part1 > part2) return 1;
      }
      return 0;
    },
  };
});
